<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息 - 智慧后勤综合管理系统</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #e0f7fa, #bbdefb, #90caf9);
            color: #333;
            min-height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }

        header {
            background: rgba(255, 255, 255, 0.9);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
            padding: 15px 0;
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .logo i {
            font-size: 28px;
            color: #2563eb;
        }

        .logo h1 {
            font-size: 24px;
            color: #2563eb;
            font-weight: 700;
        }

        .nav-links {
            display: flex;
            gap: 25px;
        }

        .nav-links a {
            text-decoration: none;
            color: #333;
            font-weight: 500;
            padding: 8px 12px;
            border-radius: 6px;
            transition: all 0.3s ease;
        }

        .nav-links a:hover, .nav-links a.active {
            background: #2563eb;
            color: white;
        }

        .nav-links .active {
            background: #2563eb;
            color: white;
        }

        .user-actions {
            display: flex;
            gap: 15px;
            align-items: center;
        }

        .user-actions button {
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .login-btn {
            background: #2563eb;
            color: white;
        }

        .register-btn {
            background: #f0f7ff;
            color: #2563eb;
            border: 1px solid #2563eb !important;
        }

        .user-actions button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        /* 用户信息展示区域 */
        .user-info {
            display: flex;
            align-items: center;
            gap: 12px;
            cursor: pointer;
            padding: 6px 12px;
            border-radius: 8px;
            transition: all 0.3s ease;
        }

        .user-info:hover {
            background: rgba(37, 99, 235, 0.1);
        }

        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: #eff6ff;
            display: flex;
            align-items: center;
            justify-content: center;
            color: #2563eb;
            font-size: 18px;
        }

        .user-name {
            font-weight: 500;
            color: #333;
            max-width: 120px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        .page-title {
            color: #2563eb;
            margin-bottom: 25px;
            padding-bottom: 15px;
            border-bottom: 2px solid #eef6ff;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .page-title i {
            font-size: 28px;
        }

        /* 个人信息样式 */
        .profile-container {
            display: grid;
            grid-template-columns: 300px 1fr;
            gap: 30px;
        }

        .profile-sidebar {
            background: white;
            border-radius: 12px;
            padding: 25px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }

        .profile-header {
            text-align: center;
            margin-bottom: 25px;
        }

        .profile-avatar {
            width: 120px;
            height: 120px;
            border-radius: 50%;
            background: #eff6ff;
            display: flex;
            align-items: center;
            justify-content: center;
            margin: 0 auto 15px;
            font-size: 48px;
            color: #2563eb;
        }

        .profile-name {
            font-size: 22px;
            font-weight: 600;
            margin-bottom: 5px;
        }

        .profile-role {
            color: #64748b;
            background: #f1f5f9;
            padding: 4px 12px;
            border-radius: 20px;
            display: inline-block;
        }

        .profile-menu {
            list-style: none;
        }

        .profile-menu li {
            padding: 12px 15px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-bottom: 5px;
        }

        .profile-menu li:hover, .profile-menu li.active {
            background: #eff6ff;
            color: #2563eb;
        }

        .profile-content {
            background: white;
            border-radius: 12px;
            padding: 30px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
        }

        .profile-section {
            margin-bottom: 30px;
        }

        .section-title {
            font-size: 20px;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
            color: #2563eb;
        }

        .info-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
            gap: 20px;
        }

        .info-item {
            margin-bottom: 15px;
        }

        .info-label {
            font-weight: 500;
            color: #64748b;
            margin-bottom: 5px;
        }

        .info-value {
            font-weight: 500;
        }

        .action-btn {
            background: #2563eb;
            color: white;
            border: none;
            padding: 10px 20px;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
            transition: all 0.3s ease;
        }

        .action-btn:hover {
            background: #1d4ed8;
            transform: translateY(-2px);
        }

        footer {
            background: rgba(0, 0, 0, 0.7);
            color: white;
            text-align: center;
            padding: 20px;
            margin-top: auto;
        }

        .footer-content {
            max-width: 1200px;
            margin: 0 auto;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .copyright {
            font-size: 14px;
        }

        .footer-links {
            display: flex;
            gap: 20px;
        }

        .footer-links a {
            color: #ddd;
            text-decoration: none;
            transition: color 0.3s ease;
        }

        .footer-links a:hover {
            color: white;
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .navbar {
                flex-direction: column;
                gap: 15px;
            }

            .nav-links {
                flex-wrap: wrap;
                justify-content: center;
            }

            .profile-container {
                grid-template-columns: 1fr;
            }

            .footer-content {
                flex-direction: column;
                gap: 15px;
            }

            .user-info {
                max-width: 150px;
            }
        }

        @media (max-width: 480px) {
            .user-info {
                max-width: 100px;
            }

            .user-name {
                font-size: 14px;
            }
        }
    </style>


    <style>    /* 订单模态框样式 */
    .order-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        display: none;
        justify-content: center;
        align-items: center;
        z-index: 9999;
    }

    .order-content {
        background: white;
        width: 600px;
        max-width: 90%;
        border-radius: 10px;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        overflow: hidden;
        max-height: 80vh;
        display: flex;
        flex-direction: column;
    }

    .order-header {
        padding: 15px 20px;
        background: #2563eb;
        color: white;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .order-header h3 {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 18px;
    }

    .close-order {
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        cursor: pointer;
    }

    .order-body {
        padding: 20px;
        overflow-y: auto;
        flex-grow: 1;
    }

    .empty-order {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 40px 0;
        color: #64748b;
    }

    .empty-order i {
        font-size: 50px;
        margin-bottom: 15px;
    }

    .order-item {
        border-bottom: 1px solid #eee;
        padding: 15px 0;
    }

    .order-item:last-child {
        border-bottom: none;
    }

    .order-item strong {
        display: inline-block;
        width: 100px;
    }

    .order-footer {
        padding: 15px 20px;
        border-top: 1px solid #eee;
        text-align: right;
    }
    </style>

</head>
<body>
<!-- 顶部导航栏 -->
<header>
    <div class="container">
        <nav class="navbar">
            <div class="logo">
                <i class="fas fa-cogs"></i>
                <h1>智慧后勤综合管理系统</h1>
            </div>
            <div class="nav-links">
                <a href="home.html">首页</a>
                <a href="mall.html">商城服务</a>
                <a href="search.html">搜索服务</a>
                <a href="profile.html" class="active">个人信息</a>
            </div>
            <div class="user-actions">
                <div class="user-info" id="user-info">
                    <div class="user-avatar">
                        <i class="fas fa-user"></i>
                    </div>
                    <div class="user-name" id="display-name">张明</div>
                </div>
            </div>
        </nav>
    </div>
</header>

<!-- 主内容区域 -->
<div class="container">
    <!-- 个人信息页面 -->
    <div>
        <div class="page-title">
            <i class="fas fa-user-circle"></i>
            <h2>个人信息</h2>
        </div>

        <div class="profile-container">
            <div class="profile-sidebar">
                <div class="profile-header">
                    <div class="profile-avatar">
                        <i class="fas fa-user"></i>
                    </div>
                    <h3 class="profile-name" id="profile-name">张明</h3>
                    <div class="profile-role">高级管理员</div>
                </div>

                <ul class="profile-menu">
                    <li class="active">个人资料</li>
                    <li>账户安全</li>
                    <li>我的订单</li>
                    <li>消息通知</li>
                    <li>系统设置</li>
                    <li onclick="logout()">退出登录</li>
                </ul>
            </div>

            <!-- 订单模态框 -->
            <div class="order-modal" id="order-modal">
                <div class="order-content">
                    <div class="order-header">
                        <h3><i class="fas fa-box"></i> 我的订单</h3>
                        <button class="close-order" id="close-order">&times;</button>
                    </div>
                    <div class="order-body" id="order-body">
                        <!-- 订单内容将在这里动态加载 -->
                        <div class="empty-order">
                            <i class="fas fa-box-open"></i>
                            <p>暂无订单记录</p>
                        </div>
                    </div>
                    <div class="order-footer">
                        <button class="action-btn" onclick="closeOrder()">关闭</button>
                    </div>
                </div>
            </div>
            <div class="profile-content">
                <div class="profile-section">
                    <h3 class="section-title">基本信息</h3>
                    <div class="info-grid">
                        <div class="info-item">
                            <div class="info-label">用户名</div>
                            <div class="info-value">zhangming</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">姓名</div>
                            <div class="info-value">张明</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">员工编号</div>
                            <div class="info-value">A20230085</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">部门</div>
                            <div class="info-value">行政部</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">职位</div>
                            <div class="info-value">后勤主管</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">联系电话</div>
                            <div class="info-value">138****5678</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">邮箱</div>
                            <div class="info-value">zhangming@company.com</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">入职日期</div>
                            <div class="info-value">2020-05-12</div>
                        </div>
                    </div>
                </div>

                <div class="profile-section">
                    <h3 class="section-title">账户信息</h3>
                    <div class="info-grid">
                        <div class="info-item">
                            <div class="info-label">账户状态</div>
                            <div class="info-value">正常</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">账户余额</div>
                            <div class="info-value">¥1,568.00</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">最后登录</div>
                            <div class="info-value">2023-08-15 14:30:22</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">登录IP</div>
                            <div class="info-value">192.168.10.25</div>
                        </div>
                    </div>
                </div>

                <div class="profile-section">
                    <h3 class="section-title">安全设置</h3>
                    <div class="info-grid">
                        <div class="info-item">
                            <div class="info-label">密码强度</div>
                            <div class="info-value">强</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">手机绑定</div>
                            <div class="info-value">已绑定</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">邮箱绑定</div>
                            <div class="info-value">已绑定</div>
                        </div>
                        <div class="info-item">
                            <div class="info-label">登录验证</div>
                            <div class="info-value">已开启</div>
                        </div>
                    </div>
                    <button class="action-btn">修改密码</button>
                    <button class="action-btn" style="background: #4b5563; margin-left: 10px;">安全设置</button>
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 底部信息 -->
<footer>
    <div class="footer-content">
        <div class="copyright">
            &copy; 2023 智慧后勤综合管理系统 | 企业后勤服务解决方案
        </div>
        <div class="footer-links">
            <a href="#">关于我们</a>
            <a href="#">服务条款</a>
            <a href="#">隐私政策</a>
            <a href="#">帮助中心</a>
            <a href="#">联系我们</a>
        </div>
    </div>
</footer>

<script>
    // 退出登录功能
    function logout() {
        // 清除本地存储的用户名
        localStorage.removeItem('currentUser');
        // 跳转到登录页面
        window.location.href = 'login.html';
    }

    // 页面加载时设置用户名
    document.addEventListener('DOMContentLoaded', function() {
        const username = localStorage.getItem('currentUser');
        if (username) {
            document.getElementById('display-name').textContent = username;
            document.getElementById('profile-name').textContent = username;
        } else {
            // 如果未登录，跳转到登录页面
            window.location.href = 'login.html';
        }
    });

    // 页面加载时绑定事件监听器
document.addEventListener('DOMContentLoaded', function () {
    // 获取“我的订单”按钮
    const ordersBtn = Array.from(document.querySelectorAll('.profile-menu li')).find(li => li.textContent.trim() === '我的订单');

    if (ordersBtn) {
        ordersBtn.addEventListener('click', function () {
            // 加载并显示订单模态框
            loadOrders();
            document.getElementById('order-modal').style.display = 'flex';
            document.body.style.overflow = 'hidden';
        });
    }

    // 关闭模态框
    document.getElementById('close-order').addEventListener('click', closeOrder);
    document.getElementById('order-modal').addEventListener('click', function (e) {
        if (e.target === this) {
            closeOrder();
        }
    });
});

// 页面加载完成后为“我的订单”菜单项添加点击事件
document.addEventListener('DOMContentLoaded', function () {
    const ordersBtn = Array.from(document.querySelectorAll('.profile-menu li')).find(li => li.textContent.trim() === '我的订单');
    if (ordersBtn) {
        ordersBtn.addEventListener('click', loadOrders);
    }

    document.getElementById('close-order').addEventListener('click', closeOrder);
    document.getElementById('order-modal').addEventListener('click', function (e) {
        if (e.target === this) closeOrder();
    });
});

// 从服务器加载订单数据
function loadOrders() {
    const username = localStorage.getItem('currentUser');
    if (!username) {
        alert('请先登录');
        return;
    }

    fetch(`/api/orders?user=${encodeURIComponent(username)}`)
        .then(res => res.json())
        .then(orders => {
            const orderBody = document.getElementById('order-body');

            if (orders.length === 0) {
                orderBody.innerHTML = `
                    <div class="empty-order">
                        <i class="fas fa-box-open"></i>
                        <p>暂无订单记录</p>
                    </div>
                `;
                return;
            }

            orderBody.innerHTML = orders.map(order => `
                <div class="order-item">
                    <p><strong>商品名称：</strong>${order.product_name}</p>
                    <p><strong>数量：</strong>${order.quantity}</p>
                    <p><strong>单价：</strong>¥${order.price.toFixed(2)}</p>
                    <p><strong>总价：</strong>¥${order.total_price.toFixed(2)}</p>
                    <p><small>下单时间：${new Date(order.order_date).toLocaleString()}</small></p>
                </div>
            `).join('');
        })
        .catch(err => {
            console.error('加载订单失败:', err);
            alert('无法加载订单信息，请稍后再试');
        });

    document.getElementById('order-modal').style.display = 'flex';
    document.body.style.overflow = 'hidden';
}

function closeOrder() {
    document.getElementById('order-modal').style.display = 'none';
    document.body.style.overflow = 'auto';
}



</script>
</body>
</html>